﻿<Window
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:loc="clr-namespace:SaryaAccounting"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	x:Class="SaryaAccounting.Window1" x:Name="Window" Title="Window1" Width="388" Height="390" FlowDirection="RightToLeft">
    <Window.Resources>
        <Style x:Key="OperationMenuButton1" TargetType="{x:Type Button}" BasedOn="{x:Null}">
            <Setter Property="Padding" Value="10" />
            <Setter Property="Margin" Value="0" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border x:Name="Border" BorderThickness="0" Background="Transparent" >
                            <ContentPresenter HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RecognizesAccessKey="True"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter TargetName="Border" Property="Background" Value="Gray" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
    <Grid>
        <Border Name="CaptionBorder" Grid.Column="0" Grid.Row="0" Grid.RowSpan="3" HorizontalAlignment="Left" Margin="5,5,0,5" Width="200" 
                                CornerRadius="4" BorderThickness="1" BorderBrush="{StaticResource LightBrush}" Background="{StaticResource BackgroundLightBrush}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="30" />
                    <ColumnDefinition Width="1" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <StackPanel Orientation="Vertical" VerticalAlignment="Bottom">
                    <Button x:Name="CloseButton" Width="20" Height="20" Margin="0,5,0,0" Focusable="False" Command="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=DataContext.CloseEditorCommand}">
                        <Button.Style>
                            <Style TargetType="{x:Type Button}">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type Button}">
                                            <Grid Background="Transparent">
                                                <Border BorderThickness="1" Background="#00000000">
                                                    <Path x:Name="closePath" Width="10" Height="10" Data="M0.28710935,3.5868225 L1.3359375,3.5868225 L3.515625,6.7626038 L3.5390625,6.7626038 L5.7070313,3.5868225 L6.7675781,3.5868225 L4.1074219,7.4481506 L6.890625,11.426666 L5.8183594,11.426666 L3.5214844,8.1044006 L3.4980469,8.1044006 L1.2011719,11.426666 L0.11718747,11.426666 L2.9238281,7.4247131 z" Fill="{StaticResource LightBrush}" RenderTransformOrigin=".5,.5" Stretch="Fill">
                                                        <Path.RenderTransform>
                                                            <TransformGroup>
                                                                <ScaleTransform />
                                                                <SkewTransform />
                                                                <RotateTransform />
                                                                <TranslateTransform />
                                                            </TransformGroup>
                                                        </Path.RenderTransform>
                                                    </Path>
                                                </Border>
                                            </Grid>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Setter TargetName="closePath" Property="Fill" Value="#FFFFAF00"/>
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </Button.Style>
                    </Button>

                    <ToggleButton x:Name="MaxAndNormalButton" Width="20" Height="20" Margin="0,7" Focusable="False">
                        <ToggleButton.Style>
                            <Style TargetType="{x:Type ToggleButton}">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type ToggleButton}">
                                            <Grid Background="Transparent">
                                                <VisualStateManager.VisualStateGroups>
                                                    <VisualStateGroup x:Name="CommonStates">
                                                        <VisualState x:Name="Normal" />
                                                        <VisualState x:Name="MouseOver">
                                                            <Storyboard>
                                                                <ColorAnimationUsingKeyFrames Storyboard.TargetName="rect1" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)">
                                                                    <EasingColorKeyFrame KeyTime="0" Value="#FFB68211" />
                                                                </ColorAnimationUsingKeyFrames>
                                                                <ColorAnimationUsingKeyFrames Storyboard.TargetName="rect2" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)">
                                                                    <EasingColorKeyFrame KeyTime="0" Value="#FFB68211" />
                                                                </ColorAnimationUsingKeyFrames>
                                                                <ColorAnimationUsingKeyFrames Storyboard.TargetName="rect2" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
                                                                    <EasingColorKeyFrame KeyTime="0" Value="#FFB68211" />
                                                                </ColorAnimationUsingKeyFrames>
                                                                <ColorAnimationUsingKeyFrames Storyboard.TargetName="rect3" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)">
                                                                    <EasingColorKeyFrame KeyTime="0" Value="#FFB68211" />
                                                                </ColorAnimationUsingKeyFrames>
                                                                <ColorAnimationUsingKeyFrames Storyboard.TargetName="rect4" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)">
                                                                    <EasingColorKeyFrame KeyTime="0" Value="#FFB68211" />
                                                                </ColorAnimationUsingKeyFrames>
                                                            </Storyboard>
                                                        </VisualState>
                                                        <VisualState x:Name="Pressed" />
                                                        <VisualState x:Name="Disabled" />
                                                    </VisualStateGroup>
                                                    <VisualStateGroup x:Name="CheckStates">
                                                        <VisualState x:Name="Checked">
                                                            <Storyboard>
                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="canvas1" Storyboard.TargetProperty="(UIElement.Visibility)">
                                                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}" />
                                                                </ObjectAnimationUsingKeyFrames>
                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="canvas2" Storyboard.TargetProperty="(UIElement.Visibility)">
                                                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
                                                                </ObjectAnimationUsingKeyFrames>
                                                            </Storyboard>
                                                        </VisualState>
                                                    </VisualStateGroup>
                                                </VisualStateManager.VisualStateGroups>
                                                <Border BorderThickness="1">
                                                    <Grid>
                                                        <Canvas x:Name="canvas1" Margin="3,3,3,3">
                                                            <Rectangle x:Name="rect1" Width="12" Height="12" Canvas.Left="0.011" Canvas.Top="0.066" Stroke="{StaticResource LightBrush}" />
                                                            <Rectangle x:Name="rect2" Width="12" Height="4" Stroke="{StaticResource LightBrush}" Fill="{StaticResource LightBrush}" />
                                                        </Canvas>
                                                        <Canvas x:Name="canvas2" Margin="3,3,3,3" Visibility="Collapsed">
                                                            <Rectangle x:Name="rect3" Width="8" Height="8" Canvas.Left="1" Canvas.Top="1" Stroke="{StaticResource LightBrush}" />
                                                            <Rectangle x:Name="rect4" Width="8" Height="8" Canvas.Left="3" Canvas.Top="3" Stroke="{StaticResource LightBrush}" />
                                                        </Canvas>
                                                    </Grid>
                                                </Border>
                                            </Grid>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </ToggleButton.Style>
                    </ToggleButton>

                    <Button x:Name="MinButton" Width="20" Height="20" Margin="0" Focusable="False">
                        <Button.Style>
                            <Style TargetType="{x:Type Button}">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type Button}">
                                            <Grid Background="Transparent">
                                                <Border BorderThickness="0" />
                                                <Rectangle x:Name="minRect" Height="2" RadiusX=".5" RadiusY=".5" Fill="{StaticResource LightBrush}" Margin="1,5" />
                                            </Grid>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Setter Property="Fill" TargetName="minRect" Value="#FFB58110"/>
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </Button.Style>
                    </Button>
                </StackPanel>

                <Rectangle Grid.Column="1" Stroke="{StaticResource LightBrush}" />
                
                <ItemsControl Grid.Column="2" Padding="2,2,2,2">
                    <Button Style="{StaticResource OperationMenuButton1}">
                        <Border BorderThickness="1,1,1,0" CornerRadius="0,4,0,0" BorderBrush="{StaticResource LightBrush}" Background="White">
                            <DockPanel>
                                <Label Content="جديد" DockPanel.Dock="Left" Foreground="#FF646464" FontFamily="mohammad art 1" FontSize="14" />
                                <Label Content="Ctrl + N" DockPanel.Dock="Right" HorizontalContentAlignment="Right" Foreground="#FF646464" FontFamily="Calibri" />
                            </DockPanel>
                        </Border>
                    </Button>
                    <Button Style="{StaticResource OperationMenuButton1}" IsEnabled="False">
                        <Border BorderThickness="1,1,1,0" BorderBrush="{StaticResource LightBrush}" Background="White">
                            <DockPanel>
                                <Label Content="حفظ" DockPanel.Dock="Left" Foreground="#FF646464" FontFamily="mohammad art 1" FontSize="14" />
                                <Label Content="Ctrl + S" DockPanel.Dock="Right" HorizontalContentAlignment="Right" Foreground="#FF646464" FontFamily="Calibri" />
                            </DockPanel>
                        </Border>
                    </Button>
                    <Button Style="{StaticResource OperationMenuButton1}">
                        <Border BorderThickness="1,1,1,0" BorderBrush="{StaticResource LightBrush}" Background="White">
                            <DockPanel>
                                <Label Content="حفظ وجديد" DockPanel.Dock="Left" Foreground="#FF646464" FontFamily="mohammad art 1" FontSize="14" />
                                <Label Content="Ctrl + Shift + S" DockPanel.Dock="Right" HorizontalContentAlignment="Right" Foreground="#FF646464" FontFamily="Calibri" />
                            </DockPanel>
                        </Border>
                    </Button>
                    <Button Style="{StaticResource OperationMenuButton1}">
                        <Border BorderThickness="1,1,1,0" BorderBrush="{StaticResource LightBrush}" Background="White">
                            <DockPanel>
                                <Label Content="حفظ وإغلاق" DockPanel.Dock="Left"  Foreground="#FF646464" FontFamily="mohammad art 1" FontSize="14" />
                                <Label Content="Ctrl + Alt + S" DockPanel.Dock="Right" HorizontalContentAlignment="Right" Foreground="#FF646464" FontFamily="Calibri" />
                            </DockPanel>
                        </Border>
                    </Button>
                    <Button Style="{StaticResource OperationMenuButton1}">
                        <Border BorderThickness="1,1,1,1" BorderBrush="{StaticResource LightBrush}" Background="White">
                            <DockPanel>
                                <Label Content="طباعة" DockPanel.Dock="Left" Foreground="#FF646464" FontFamily="mohammad art 1" FontSize="14" />
                                <Label Content="Ctrl + P" DockPanel.Dock="Right" HorizontalContentAlignment="Right" Foreground="#FF646464" FontFamily="Calibri" />
                            </DockPanel>
                        </Border>
                    </Button>
                    <Separator />
                    <Button Style="{StaticResource OperationMenuButton1}">
                        <Border BorderThickness="1,1,1,0" BorderBrush="{StaticResource LightBrush}" Background="White">
                            <DockPanel>
                                <Label Content="السجل الأول" DockPanel.Dock="Left" Foreground="#FF646464" FontFamily="mohammad art 1" FontSize="14" />
                                <Label Content="Ctrl + Home" DockPanel.Dock="Right" HorizontalContentAlignment="Right" Foreground="#FF646464" FontFamily="Calibri" />
                            </DockPanel>
                        </Border>
                    </Button>
                    <Button Style="{StaticResource OperationMenuButton1}">
                        <Border BorderThickness="1,1,1,0" BorderBrush="{StaticResource LightBrush}" Background="White">
                            <DockPanel>
                                <Label Content="السجل السابق" DockPanel.Dock="Left" Foreground="#FF646464" FontFamily="mohammad art 1" FontSize="14" />
                                <Label Content="Ctrl + Left" DockPanel.Dock="Right" HorizontalContentAlignment="Right" Foreground="#FF646464" FontFamily="Calibri" />
                            </DockPanel>
                        </Border>
                    </Button>
                    <Button Style="{StaticResource OperationMenuButton1}">
                        <Border BorderThickness="1,1,1,0" BorderBrush="{StaticResource LightBrush}" Background="White">
                            <DockPanel>
                                <Label Content="السجل التالي" DockPanel.Dock="Left" Foreground="#FF646464" FontFamily="mohammad art 1" FontSize="14" />
                                <Label Content="Ctrl + Right" DockPanel.Dock="Right" HorizontalContentAlignment="Right" Foreground="#FF646464" FontFamily="Calibri" />
                            </DockPanel>
                        </Border>
                    </Button>
                    <Button Style="{StaticResource OperationMenuButton1}">
                        <Border BorderThickness="1,1,1,1" BorderBrush="{StaticResource LightBrush}" Background="White">
                            <DockPanel>
                                <Label Content="السجل الأخير" DockPanel.Dock="Left" Foreground="#FF646464" FontFamily="mohammad art 1" FontSize="14" />
                                <Label Content="Ctrl + End" DockPanel.Dock="Right" HorizontalContentAlignment="Right" Foreground="#FF646464" FontFamily="Calibri" />
                            </DockPanel>
                        </Border>
                    </Button>
                    <Separator />
                    <Button Style="{StaticResource OperationMenuButton1}">
                        <Border BorderThickness="1,1,1,1" CornerRadius="0,0,4,0"  BorderBrush="{StaticResource LightBrush}" Background="White">
                            <DockPanel>
                                <Label Content="إغلاق" DockPanel.Dock="Left" Foreground="#FF646464" FontFamily="mohammad art 1" FontSize="14" />
                                <Label Content="Ctrl + F4" DockPanel.Dock="Right" HorizontalContentAlignment="Right" Foreground="#FF646464" FontFamily="Calibri" />
                            </DockPanel>
                        </Border>
                    </Button>
                </ItemsControl>
            </Grid>
        </Border>
        <ToggleButton x:Name="OperationsMenuButton" Width="20" Margin="7,10,339,0" Focusable="False" Height="20" VerticalAlignment="Top">
            <ToggleButton.Triggers>
                <EventTrigger SourceName="OperationsMenuButton" RoutedEvent="ToggleButton.Checked">
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="CaptionBorder" Storyboard.TargetProperty="(Border.Width)" Duration="00:00:01" From="30" To="200" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
                <EventTrigger SourceName="OperationsMenuButton" RoutedEvent="ToggleButton.Unchecked">
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="CaptionBorder" Storyboard.TargetProperty="(Border.Width)" Duration="00:00:01" From="200" To="30" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </ToggleButton.Triggers>
            <ToggleButton.Style>
                <Style TargetType="{x:Type ToggleButton}">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type ToggleButton}">
                                <Rectangle Fill="Beige" Stroke="{StaticResource LightBrush}" Width="10" Height="10" ContextMenu="{StaticResource OperationsMenu}" />
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </ToggleButton.Style>
        </ToggleButton>
    </Grid>
</Window>